package com.qiniu.util;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

public class CompareMap {
	
	public static Set<String> compare(Map<String, String> m1,Map<String, String> m2){
		Set<String> set = new HashSet<String>();
		long l = System.currentTimeMillis();
		
		// 迭代循环
		Iterator<Entry<String, String>> iter1 = m1.entrySet().iterator();
		while (iter1.hasNext()) {
			// 循环 遍历 m1
			Map.Entry<String, String> entry1 = (Entry<String, String>) iter1.next();
			// 取出 m1的 value1
			String m1value = entry1.getValue() == null ? "" : entry1.getValue();
			
			// 取出m2与m1相同key的 value2 
			String m2value = m2.get(entry1.getKey()) == null ? "" : m2.get(entry1.getKey());
			
			// value1与value2的值进行比较
			if (!m1value.equals(m2value)) {// 不想等取出来
				set.add(entry1.getValue());
			}
		}
		long jj = System.currentTimeMillis();
		System.out.println("消耗时长:"+(jj-l));
		return set;
	}
}
